#pragma once
#include <QString>
#include <vector>
#include <string>

typedef std::vector<int> vecInt;
typedef vecInt::iterator		vecIntIt;
typedef vecInt::const_iterator	vecIntIt_C;

typedef std::vector<QString>	vecStr;
typedef vecStr::iterator		vecStrIt;
typedef vecStr::const_iterator	vecStrIt_C;

enum HBFileSysType { HB_FS_Failed, HB_FS_FAT32, HB_FS_NTFS, HB_FS_OTHER };
class CHBGlobalTool
{
public:
	static QString TrimStr(QString &sSrcStr, const QString& sTargets);
	static QString TrimStrLeft(QString &sSrcStr, const QString& sTargets);
	static QString TrimStrRight(QString &sSrcStr, const QString& sTargets);

	static vecStr SplitStr( const QString &str, const QString &sepStr );
	static QString Int2Str(qint64 iVal);
	static QString Int2Str(int iVal);
	
	static HBFileSysType GetFileSysByFilePath( const QString& sFilePathName );
	static QString GetFilePathName( const QString& sFilePath, const QString& sFileName );

	static qint64 GetFileSize( const QString& sFilePathName );
	static bool QuickCreateFile( const QString& sFilePathName, qint64 iFileSize );

public:
	template<class Type>
	static void DeepCopyVector(std::vector<Type*>& dest, const std::vector<Type*>& src)
	{
		for (std::vector<Type*>::const_iterator it=src.begin(); it!=src.end(); it++)
		{
			dest.push_back(new Type(*(*it)));
		}
	}

	template<class Type>
	static void DeleteVector(std::vector<Type*>& vec)
	{
		for (std::vector<Type*>::iterator it=vec.begin(); it!=vec.end(); it++)
		{
			delete (*it);
		}
		vec.clear();
	}
};

#define HB_S2Q(qstr)			(QString::fromStdString(qstr))
#define HB_Q2S(str)				(str.toStdString())
#define HB_UP(userName, pwd)	(HB_S2Q(userName) + ":" + HB_S2Q(pwd))